package com.bw.documents.preview

import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.bw.documents.databinding.ActivityVideoBinding
import tv.danmaku.ijk.media.player.IjkMediaPlayer

@Route(path = "/documents/VideoActivity")
class VideoActivity : AppCompatActivity() {

    private val v : ActivityVideoBinding by lazy { ActivityVideoBinding.inflate(LayoutInflater.from(this)) }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(v.root)
        IjkMediaPlayer.loadLibrariesOnce(null)
        IjkMediaPlayer.native_profileBegin("libijkplayer.so")
        val path = intent.extras!!.getString("path")
        v.videoPage.titleTv.text = "视频预览"
        v.videoPage.backImg.setOnClickListener { finish() }
        v.videoView.setVideoPath(path)
        v.videoView.start()
    }

    override fun onStop() {
        super.onStop()
        v.videoView.stopPlayback()
        v.videoView.release(true)
        IjkMediaPlayer.native_profileEnd()
    }

}